package tec;

class PassagerStandard implements Passager,Usager {
    
    private String nom;
    private int destination;
    private EtatPassager monEtat;
    
    public PassagerStandard(String nom, int destination) {
  	
	this.destination=destination;
	monEtat= new EtatPassager(Etat.DEHORS);
	this.nom = nom;
    }
    
    public String nom(){
	return nom;
    }
    
    public boolean estDehors() {
	return monEtat.estExterieur();
    }
    
    public boolean estAssis() {
	return monEtat.estAssis();
    }
    
    public boolean estDebout() {
	return monEtat.estDebout();
    }
    
    public void accepterSortie() {
	this.monEtat=monEtat.DEHORS;
    }
    
    public void accepterPlaceAssise() {
        this.monEtat=monEtat.ASSIS;
    }
    
    public void accepterPlaceDebout() {
	this.monEtat=monEtat.DEBOUT;
    }
    public void nouvelArret(Bus bus, int numeroArret){
	if(numeroArret >= destination)
	    bus.demanderSortie(this);
    }
    
    public void monterDans(Transport t){
	//places assises prioritaires
	Bus bus = (Bus) t;
	if (bus.aPlaceAssise())
	    bus.demanderPlaceAssise(this);
	else if (bus.aPlaceDebout())
	    bus.demanderPlaceDebout(this);
	
    }
    public String toString() {
	StringBuffer str = new StringBuffer();
	str.append(nom);
	if(estAssis())
	    str.append(" assis");
	else if(estDebout())
	    str.append(" debout");
	else str.append(" dehors");
	return str.toString();
    }
    
}
